package homework1.exp1;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @author fengq
 */
public class JavaTest1 {
    public static void main(String[] args) {
        ArrayList list = new ArrayList();
        list.add("张三");
        list.add("李四");
        list.add("王五");
        list.add(2,"杰伦");
        System.out.println("使用Iterator 遍历，分别是：");
        Iterator<Object> iterator = list.iterator();
        while(iterator.hasNext()){
            String name=(String)iterator.next();
            System.out.println(name);
        }
    }
}
